<template>
  <div>
    <el-table v-loading="loading" :data="list">
      <!-- <el-table-column type="selection" width="50" align="center" /> -->
      <el-table-column label="单号" align="center" key="houseSweepId" prop="houseSweepId" :show-overflow-tooltip="true" />
      <el-table-column label="房间" align="center" key="fullAddress" prop="fullAddress" />
      <el-table-column label="分类" align="center" key="sweepType" prop="sweepType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sweep_type" :value="scope.row.sweepType" />
        </template>
      </el-table-column>
      <el-table-column label="预计开始时间" align="center" prop="scheduledTime">
        <template slot-scope="scope">
          <span>{{ scope.row.scheduledTime | formatDate }}</span>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="sweepState">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.dict_sweep_state" :value="scope.row.sweepState" />
        </template>
      </el-table-column>
      <el-table-column label="打扫人" align="center" key="homeSweepName" prop="homeSweepName" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope" v-if="scope.row.userId !== 1">
          <el-button size="mini" type="text" icon="el-icon-info" @click="handleDetail(scope.row)"
            v-hasPermi="['enterprise:sweep:query']">详情</el-button>
          <el-button size="mini" type="text" icon="el-icon-user" @click="handleAssign(scope.row)"
            v-hasPermi="['enterprise:sweep:edit']" v-if="scope.row.sweepState == 1">指定人员</el-button>
          <el-button size="mini" type="text" icon="el-icon-user" @click="handleReplace(scope.row)"
            v-hasPermi="['enterprise:sweep:change']" v-if="scope.row.sweepState == 2">更换人员</el-button>
          <!-- <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
            v-hasPermi="['enterprise:sweep:remove']">删除</el-button> -->
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
    <detail v-model="detailVisible" :data="sweepInfo" />
    <assign v-model="assignVisible" :data="sweepInfo" @success="getList" />
    <replace v-model="replaceVisible" :data="sweepInfo" @success="getList" />
  </div>
</template>

<script>
import detail from './detail.vue';
import assign from './assign.vue';
import replace from './replace.vue';
import { listSweep } from "@/api/houseCleaning/sweep"
export default {
  name: "Index",
  dicts: ['dict_sweep_state', 'sweep_type'],
  components: { detail, assign, replace },
  props: {
    orderInfo: {
      default: {}
    }
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 表格数据
      list: null,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      //显示 详情
      detailVisible: false,
      //显示 指派人员
      assignVisible: false,
      //显示 更换人员
      replaceVisible: false,
      // 日期范围
      dateRange: [],
      // 表单参数
      form: {},
      //用户id
      userId: undefined,
      //打扫信息
      sweepInfo: undefined,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderId:undefined,
        houseSweepId: undefined,
        fullAddress: undefined,
        sweepType: undefined,
        sweepState: undefined,
        homeSweepName: undefined
      },
    };
  },
  watch: {
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询用户列表 */
    getList() {
      this.loading = true;
      this.queryParams.orderId = this.orderInfo.orderId
      listSweep(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
        this.list = response.rows;
        this.total = response.total;
        this.loading = false;
      })
    },
    handleDetail(row) {
      this.sweepInfo = {...row}
      this.detailVisible = true
    },
    // 人员指派
    handleAssign(row) {
      this.sweepInfo = { ...row }
      this.assignVisible = true
    },
    // 更换人员
    handleReplace(row) {
      this.sweepInfo = { ...row }
      this.replaceVisible = true
    },
  }
}
</script>

<style lang="scss" scoped></style>
